<template>
  <div>
    <eagle-page-list
      ref="eaglePageList"
      @bindData="bindData"
      :queryParams="queryParams"
      :controller="controller"
      :conditions="conditions"
      placeholder="请输入事故名称,事故编号搜索"
      :pageSize="20"
    >
      <div slot="list">
        <van-cell
          class="card"
          v-for="(item, index) in list"
          :key="index"
        >
          <div>
            <div @click="detail(item)">
              <van-row
                gutter="15"
                style="word-break:break-all"
              >
                <van-col>
                  <b style="font-size: 13px">{{ item.AccidentName }}</b>
                </van-col>
              </van-row>
              <van-row gutter="15">
                <van-col>
                  <img
                    class="icon"
                    src="@/assets/Images/AppIcon/icon_list_type.png"
                  />事故编号：{{ item.AccidentNumber }}
                </van-col>
              </van-row>
              <!-- <van-row gutter="20">
                                <van-col style="word-break:break-all" >
                                    <img class="icon" src="@/assets/Images/AppIcon/icon_list_type.png" />事故名称:{{ item.AccidentName }}
                                </van-col>
                            </van-row> -->

              <van-row gutter="20">
                <van-col>
                  <img
                    class="icon"
                    src="@/assets/Images/AppIcon/icon_list_date.png"
                  />事故发生日期：{{ item.AccidentDate | formatDateTime }}
                </van-col>
              </van-row>
              <van-row gutter="20">
                <van-col>
                  <img
                    class="icon"
                    src="@/assets/Images/AppIcon/icon_list_type.png"
                  />事故分类：{{ item.AttidentClassification }}
                </van-col>
              </van-row>
              <van-row gutter="20">
                <van-col>
                  <img
                    class="icon"
                    src="@/assets/Images/AppIcon/icon_list_type.png"
                  />事故等级：{{ item.AttidentgRading }}
                </van-col>
              </van-row>
              <van-row gutter="20">
                <van-col>
                  <img
                    class="icon"
                    src="@/assets/Images/AppIcon/icon_list_type.png"
                  />潜在风险：{{ item.PotentialRisk }}
                </van-col>
              </van-row>
              <van-row gutter="20">
                <van-col>
                  <img
                    class="icon"
                    src="@/assets/Images/AppIcon/icon_list_date.png"
                  />创建日期：{{ item.CreateDate | formatDateTime }}
                </van-col>
              </van-row>
              <van-row gutter="20">
                <van-col>
                  <img
                    class="icon"
                    src="@/assets/Images/AppIcon/icon_list_user.png"
                  />调查组长：{{ item.UserChnName1 }}
                </van-col>
              </van-row>

              <van-row gutter="20">
                <van-col>
                  <img
                    class="icon"
                    src="@/assets/Images/AppIcon/icon_list_type.png"
                  />区域部门：{{ item.AccidentDepartmentName }}
                </van-col>
              </van-row>
              <van-row gutter="20">
                <van-col>
                  <img
                    class="icon"
                    src="@/assets/Images/AppIcon/icon_list_type.png"
                  />状态：{{ GetStatus(item.Status) }}
                </van-col>
              </van-row>
              <van-divider />
            </div>
            <div class="op_btn">
              <!-- <div class="btn_item" v-if="(rightValue & 1) > 0&&item.Status ==0" @click="edit(item)">
                                <img src="@/assets/Images/AppIcon/icon_list_edit.png" alt="" />
                                <div class="mr-10">编辑</div>
                            </div> -->
              <div
                class="btn_item"
                v-if="item.Status ==0"
                @click="edit(item)"
              >
                <img
                  src="@/assets/Images/AppIcon/icon_list_edit.png"
                  alt=""
                />
                <div class="mr-10">编辑</div>
              </div>
              <div
                class="btn_item"
                v-if="item.Status ==0 && item.IsAssignedMe && item.SystemIsAssist=='A'"
                @click="Assist(item)"
              >
                <img
                  src="@/assets/Images/AppIcon/icon_list_user.png"
                  alt=""
                />
                <div class="mr-10">设置协助人员</div>
              </div>
              <div
                class="btn_item"
                @click="goApprove(item)"
              >
                <img
                  src="@/assets/Images/AppIcon/icon_list_edit.png"
                  alt=""
                />
                <div class="mr-10">审批历史</div>
              </div>

            </div>
          </div>
        </van-cell>
      </div>
      <!-- <div title="事故调查报告"> -->

      <!-- <van-list :finished="myFinished" v-model="myLoading" finished-text="没有更多了">
                    <van-cell class="card" v-for="(item, index) in myList2" :key="index">
                        <div>
                            <div>
                                <van-row gutter="15">
                                    <van-col>
                                        <img class="icon" src="@/assets/Images/AppIcon/icon_list_type.png" />事故编号:{{ item.AccidentNumber }}
                                    </van-col>
                                </van-row>
                                <van-row gutter="15">
                                    <van-col>
                                        <img class="icon" src="@/assets/Images/AppIcon/icon_list_type.png" />事故名称:{{ item.AccidentName }}
                                    </van-col>
                                </van-row>
                                <van-row gutter="15">
                                    <van-col>
                                        <img class="icon" src="@/assets/Images/AppIcon/icon_list_type.png" />HSE管理要素:{{ item.HSEManagement }}
                                    </van-col>
                                </van-row>
                                <van-row gutter="20">
                                    <van-col>
                                        <img class="icon" src="@/assets/Images/AppIcon/icon_list_type.png" />工艺分类:{{ item.ProcessClassification }}
                                    </van-col>
                                </van-row>
                                <van-row gutter="20">
                                    <van-col>
                                        <img class="icon" src="@/assets/Images/AppIcon/icon_list_type.png" />事故分类:{{ item.AttidentClassification }}
                                    </van-col>
                                </van-row>
                                <van-row gutter="20">
                                    <van-col>
                                        <img class="icon" src="@/assets/Images/AppIcon/icon_list_type.png" /> 事故分级:{{ item.AttidentgRading }}
                                    </van-col>
                                </van-row>
                                <van-row gutter="20">
                                    <van-col>
                                        <img class="icon" src="@/assets/Images/AppIcon/icon_list_type.png" />伤害/职业病:{{ item.Harm }}
                                    </van-col>
                                </van-row>
                                <van-row gutter="20">
                                    <van-col>
                                        <img class="icon" src="@/assets/Images/AppIcon/icon_list_type.png" />状态:{{ GetStatus(item.Status) }}
                                    </van-col>
                                </van-row>
                                <van-row gutter="20">
                                    <van-col>
                                        <img class="icon" src="@/assets/Images/AppIcon/icon_list_date.png" />事故日期：{{ item.AccidentDate | formatDate }}
                                    </van-col>
                                </van-row>
                                <van-row gutter="20">
                                    <van-col>
                                        <img class="icon" src="@/assets/Images/AppIcon/icon_list_user.png" />录入人：{{ item.CreateChName }}
                                    </van-col>
                                </van-row>
                                <van-row gutter="20">
                                    <van-col>
                                        <img class="icon" src="@/assets/Images/AppIcon/icon_list_date.png" />录入时间：{{ item.CreateDate | formatDate }}
                                    </van-col>
                                </van-row>
                                <van-divider />
                                <div class="op_btn">
                                    <div class="btn_item" @click="detail(item)">
                                            <img src="@/assets/Images/AppIcon/icon_detail_riskunit_identification.png" alt="" />
                                            <div class="mr-10">详情</div>
                                        </div>
                                    <div class="btn_item" v-if="item.Status ==0" @click="edit(item)">
                                        <img src="@/assets/Images/AppIcon/icon_list_edit.png" alt="" />
                                        <div class="mr-10">编辑</div>
                                    </div>
                                    <div class="btn_item" v-if="item.Status ==0" @click="deletePlan(item)">
                                        <img src="@/assets/Images/AppIcon/icon_list_delete.png" alt="" />
                                        <div class="mr-10">删除</div>
                                    </div>
                                    <div class="btn_item" v-if="item.Status ==0" @click="Assist(item)">
                                        <img src="@/assets/Images/AppIcon/icon_list_delete.png" alt="" />
                                        <div class="mr-10">协助</div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </van-cell>
                </van-list> -->
      <!-- </div> -->
    </eagle-page-list>
  </div>
</template>
<script>
import UserChooseDialog from "@/views/components/user/userChooseDialog.vue";
import { GetPageData, deletePlan } from "@/api/WhInvestigationReport";
import investigateList from "@/views/wh/AccidentInvestigate/List.vue";
import { getMenuByMenuCode } from "@/api/common";
export default {
  components: { investigateList, UserChooseDialog },
  data() {
    return {
      list: [],
      conditions: {},
      controller: "/WhInvestigationReport",
      queryParams: {
        dataType: "List",
        keywords: "",
      },
      rightValue: 0,
      userChooseDialogShow: false,
    };
  },
  created() {
    this.getMenuByMenuCode();
  },
  mounted() {},
  methods: {
    // onSearch() {
    //     var conditions = [];
    //     if (this.value) {
    //         conditions.push({
    //             Name: "Keywords",
    //             DisplayName: this.value,
    //             Value: this.value,
    //             Operator: "like",
    //             DataType: "String",
    //         });
    //     }
    //     this.filter.page = 0;
    //     this.filter.conditions = JSON.stringify(conditions);
    //     //this.getList();
    // },
    // clearSearch() {
    //     this.filter = {
    //         page: 0,
    //         dataType: "List",
    //     };
    //     this.value = "";
    //     //this.getList();
    // },
    // getMyList() {
    //     //调查报告显示
    //     this.myLoading = true;
    //     GetPageData(this.filter).then((res) => {
    //         this.myLoading = false;
    //         this.myList2 = res.data.Data;
    //         this.filter.page = res.data.PageIndex;
    //     });
    // },
    GetStatus(val) {
      if (val == 0) {
        return "未提交";
      } else if (val == 5) {
        return "审批中";
      } else {
        return "已审批";
      }
    },
    // myOnLoad() {
    //     this.myLoading = true;
    //     this.filter.page;
    //     list(this.filter).then((res) => {
    //         this.myLoading = false;
    //         this.filter.page = res.data.PageIndex;
    //         this.myList = this.myList.concat(res.data.Data);
    //         if (!res.data.HasNextPage) {
    //             this.myFinished = true;
    //         }
    //     });
    // },
    // onLoad() {
    //     this.loading = true;
    //     ++this.filter.page;
    // },

    // search(conditions) {
    //     this.conditions = [];
    //     this.queryPage();
    // },
    // queryPage() {
    //     let _this = this;
    //     _this.$refs.eaglePageList.search({
    //         conditions: _this.conditions,
    //         params: { keywords: this.searchValue },
    //     });
    // },
    bindData(data) {
      this.list = [];
      if (data) {
        this.list = data;
      }
    },
    getMenuByMenuCode() {
      var me = this;
      getMenuByMenuCode("WH_Accident_Investigation_Report").then((res) => {
        me.rightValue = res.data ? res.data.RoleRightValue : 0;
      });
    },
    goApprove(item) {
      this.$router.push({
        path: "/AccidentInitReportApprove",
        query: {
          recordID: item.ID,
          opController: "WHInvestigationReport",
        },
      });
    },
    deletePlan(item) {
      //调查报告删除
      const that = this;

      that.$dialog
        .confirm({
          title: "询问",
          message: "您确定要删除该调查报告吗？",
        })
        .then(() => {
          deletePlan({ id: item.ID }).then((res) => {
            this.$toast.success("删除成功！");
            that.queryPage();
          });
        })
        .catch(() => {
          // on cancel
        });
    },

    Assist(item) {
      this.$router.push({
        path: "/AssistSendList",
        query: {
          AccidentNumber: item.AccidentNumber,
        },
      });
    },
    edit(item) {
      //调查报告编辑;
      if (item.ID > 0) {
        this.isEdit = true;
      } else {
        this.isEdit = false;
      }
      this.$router.push({
        path: "/AccidentInvestigate/Detail",
        query: { id: item.ID },
      });
    },
    userChooseCallback(userlist) {
      if (userlist) {
        const code = userlist.map((item) => {
          return item.code;
        });
        const name = userlist.map((item) => {
          return item.name;
        });
        this.data.CheckNames = name.join(",");
        this.data.CheckCodes = code.join(",");
      }
      this.userChooseDialogShow = false;
    },
    tabChange(val) {
      this.tabName = val;
    },
    detail(item) {
      this.$router.push({
        path: "/AccidentInvestigate/View",
        query: { id: item.ID },
      });
    },
  },
};
</script>
<style lang="less" scoped>
.register-form {
}
.phone {
  position: relative;
  .code {
    position: absolute;
    right: 20px;
    top: 20px;
    font-size: 12px;
  }
}
.register-info {
  background-color: #e8f1f8;
  padding-bottom: 20px;
}
.img-box {
  height: 50px;
  width: 50px;
  padding: 10px;
  position: absolute;
  left: 50%;
  top: 60px;
  background-color: #fff;
  border-radius: 50%;
  overflow: hidden;
}
.popup-title {
  line-height: 35px;
  padding: 10px;
  font-size: 15px;
  padding-left: 20px;
}

.op_btn {
  display: flex;
  justify-content: flex-end;
  .btn_item {
    display: flex;
    align-items: center;
    img {
      height: 15px;
      width: 15px;
      margin-right: 5px;
    }
  }
}

.search-box {
  height: 1rem;
}
</style>